<?php
class Controller_App_Category extends Controller_App_Template
{
    public function __construct ($req, $res)
    {
        $this->template = "smarty:app/category";
        parent::__construct($req, $res);
    }

    // 分类入口
    public function action_index ()
    {
        $cats = App_Category::goods_categories();
        $this->template->set('categories', $cats);
        
        $title_json  = App_Util::buildClientTitleJson('back', 'none', '分类', 'message', 'none', '');
        $bottom_json = App_Util::buildClientBottomJson('block', 'category');
        
        $this->template->set('title_json',   $title_json);
        $this->template->set('bottom_json',  $bottom_json);
    }

    // 二级分类
    public function action_sub ($nid, $offset = 0, $limit = 10)
    {
        $items = App_CategoryGl::items($nid, 0, 10);
        $this->template->set('items', $items);
        $this->template->set_filename('smarty:app/category_sub');
        
        $title_json  = App_Util::buildClientTitleJson('back', 'block', '分类', 'message', 'none', '');
        $bottom_json = App_Util::buildClientBottomJson('block', 'homepage');
        
        $this->template->set('title_json',   $title_json);
        $this->template->set('bottom_json',  $bottom_json);
    }
}
